package cc.jinglupeng.kom;

import cc.jinglupeng.kom.util.KomConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan("cc.jinglupeng.kom")
public class Application {

    private static Logger logger = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(Application.class);
        ConfigurableApplicationContext context = application.run(args);
        ConfigurableEnvironment environment = context.getEnvironment();
        String zkHostPorts = environment.getProperty("zk.hostPorts");
        String zkTimeout = environment.getProperty("zk.timeout");

        KomConfig.put("zk.hostPorts", zkHostPorts);
        KomConfig.put("zk.timeout", zkTimeout);

        logger.info("zk.hostPorts {}", zkHostPorts);
        logger.info("zk.timeout {}", zkTimeout);
    }

}
